package com.cskaoyan.controller;


import com.cskaoyan.bean.Keyword;
import com.cskaoyan.bo.KeywordUpdateBO;
import com.cskaoyan.service.KeyService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.KeyVO;
import com.cskaoyan.vo.KeywordListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class KeyController {
    @Autowired
    KeyService keyService;
    @RequestMapping("admin/keyword/list")
    public BaseRespVo list(Integer page,Integer limit,String keyword,String url,String sort,String order){
        KeywordListVO keywordListVO =  keyService.list(page,limit,keyword,url,sort,order);
        return BaseRespVo.ok(keywordListVO);
    }

    @RequestMapping("admin/keyword/create")
    public BaseRespVo create(@RequestBody KeywordListVO.ItemsBean itemsBean){
        KeywordListVO.ItemsBean bean =  keyService.create(itemsBean);
        return BaseRespVo.ok(bean);
    }
    @RequestMapping("admin/keyword/delete")
    public BaseRespVo delete(@RequestBody KeywordUpdateBO keyworddelete){
        keyService.delete(keyworddelete);
        return BaseRespVo.ok();
    }

    @RequestMapping("admin/keyword/update")
    public BaseRespVo update(@RequestBody KeywordUpdateBO keywordUpdate){
        Keyword keyword = keyService.update(keywordUpdate);
        return BaseRespVo.ok(keyword);
    }
//    @RequestMapping("admin/keyword/delete")
//    public BaseRespVo keyDelete(Keyword keyword){
//
//    }
}
